Conversation
|
The design follows a clear object-oriented approach with well-defined classes and responsibilities.
public class Bagel implements Item { ... }
|
|
The Problem with Inheritance Here A Customer is-a MemberPublic (inheritance relationship) All Customers automatically get all MemberPublic behaviors This creates several potential issues: Inheritance is rigid - What if you need a Customer that isn't a MemberPublic? Future changes become difficult - Changing MemberPublic affects all Customers Multiple roles problem - What if someone is both a Manager and Customer? Over-inheritance - Customers inherit all MemberPublic methods even if irrelevant Why Composition Works Better A Customer has-a MemberPublic (composition relationship) More flexible and maintainable design `public class MemberPublic { } public class Customer { }` |
|
I think there might have been a misunderstanding, probably because of my class diagram or domain model. But the idea I have is that they are distinct classes, so Customer and MemberPublic are their own classes, without anything in common. Can I just go with that approach? I don't quite understand why a customer needs to have an instance of MemberPublic. Is it just implying that a customer can also be a member of public? |
Yea, the idea is that a customer can also be a member of the public, and a manager can be a customer, etc. But we can stick with your approach of having unrelated classes |
… methods in some as well
|
Regarding the methods calculateTotalCostOfBasket and showCostOfItemBeforeAdding, are these methods that should be in the Basket class? Then let the customer call these methods from their class through a basket instance? |
calculateTotalCostOfBasket - I would put this in the basket c;lass |
…ss diagram and domain model
… and add some tests later
…s partially done.
No description provided.